package com.bai.boot.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

/**
 * 拦截器的注册
 *
 * @author 27471
 * Time : 2022/10/1 19:03
 */
public class LoginInterceptorConfigurer implements WebMvcConfigurer {

    //自定义拦截器进行注册
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //创建自定义的拦截器
        HandlerInterceptor interceptor = new LoginInterceptor();
        //配置白名单
        List<String> list= new ArrayList<>();
        list.add("/css/**");
        //拦截器的注册
        registry.addInterceptor(interceptor)
                .addPathPatterns("/**")//表示要拦截的url是什么
                .excludePathPatterns(list);//除了什么之外
    }
}
